<template>
  <!-- 手机页开始 -->
  <div class="container">
    <div class="home-banner">
      <a href="#"><img src="@/assets/img/长条.png" alt=""></a>
    </div>
    <div class="Productpage">
      <div class="contitle">
        <span class="names">小米手机</span>
        <span class="more" @click="getMore"><a>查看更多<i class="iconfont">&#xe604;</i></a></span>
      </div>
      <div class="middle">
        <div class="lecto">
          <a href="#"><img src="@/assets/img/K70.png" alt=""></a>
        </div>
        <div class="apparel">
          <ul>
            <li v-for="item in filteredData" :key="item.id" @click="getDetailed(item.id)">
              <a>
                <img :src="item.src" alt="">
                <h3 class="recto_title">{{ item.Chinesename }}</h3>
                <p class="recto_desc">{{ item.introduce }}</p>
                <p class="recto_price">{{ item.theprice }}起</p>
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="Productpage">
      <div class="contitle">
        <span class="names">华为手机</span>
        <span class="more" @click="getMore"><a>查看更多<i class="iconfont">&#xe604;</i></a></span>
      </div>
      <div class="middle">
        <div class="lecto">
          <a href="#"><img src="@/assets/img/St01.jpg" alt=""></a>
        </div>
        <div class="apparel">
          <ul>
            <li v-for="item in filteredDatas" :key="item.id" @click="getDetailed(item.id)">
              <a>
                <img :src="item.src" alt="">
                <h3 class="recto_title">{{ item.Chinesename }}</h3>
                <p class="recto_desc">{{ item.introduce }}</p>
                <p class="recto_price">{{ item.theprice }}起</p>
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>

    <!-- <div class="tail-banner">
      <a href="#"><img src="@/assets/img/笔.png" alt=""></a>
    </div> -->
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Array,
    }
  },
  computed: {
    filteredData() {
      // 返回前8个项目
      return this.data.slice(0, 8);
    },
    filteredDatas() {
      // 返回前8个项目
      return this.data.slice(8, 16);
    },
  },
  methods: {
    //跳转
    //子传父
    getDetailed(id) {
      // console.log(id);
      // 触发自定义事件并传递 id
      this.$emit('get-detailed', id);
    },
    //子传父
    getMore() {
      this.$emit('get-more');
    }
  }

}
</script>

<style scoped>
/* @import url('../../assets/css/index.css'); */
@import url('../../assets/css/font_4367545_5vuckvup5pp/iconfont.css');

/* 商品页开始 */
.container {
  width: 100%;
  height: 1800px;
  margin: 280px auto;
  background-color: #f7f7f7;
}

.contitle {
  margin: 60px auto;
  display: flex;
  justify-content: space-between;
  width: 1226px;
  height: 5px;
  background-color: #f7f7f7;
}

.names {
  color: #333;
  font-size: 25px;
  font-weight: 200;
  line-height: 50px;
}

.more a {
  cursor: pointer;
  color: #424242;
  font-size: 16px;
  transition: all .4s;
  line-height: 50px;
  text-align: center;
}

.more a i {
  margin-right: 10px;
  margin-left: 10px;
  width: 20px;
  height: 22px;
  display: inline-block;
  background-color: #b0b0b0;
  border-radius: 50%;
  text-align: center;
  line-height: 22px;
  color: #f7f7f7;
  font-size: 23px;
  transition: all .4s;
}

.more a:hover {
  color: #ff6700;
}

.more a:hover i {
  background-color: #ff6700;
  color: #fff;
}

.middle {
  margin: 10px auto;
  display: flex;
  justify-content: space-between;
  width: 1226px;
  height: 614px;
  transition: all .2s linear;
}

.lecto {
  width: 234px;
  height: 614px;
  transition: all 2s;
}

.lecto a img {
  width: 100%;
  height: 100%;
  /* overflow: hidden; */
  transition: all 2s;
}

.lecto :hover {
  transform: translateY(-2px);
  /* box-shadow: 0 15px 30px rgba(0, 0, 0, .1); */
}

.recto {
  width: 992px;
  height: 614px;
}

.recto ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.recto li {
  width: 234px;
  height: 300px;
  background-color: #fff;
  transition: all .4s linear;
}

.recto ul li:nth-child(5),
.recto ul li:nth-child(6),
.recto ul li:nth-child(7),
.recto ul li:nth-child(8) {
  margin-top: 14px;
}

.recto ul li:hover {
  transform: translateY(1px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, .1);
}

.recto li img {
  display: block;
  width: 160px;
  height: 160px;
  overflow: hidden;
  margin: 10px auto;
}

.recto_title,
.recto_desc {
  width: 214px;
  margin: 0 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recto_title {
  height: 21px;
  margin-bottom: 2px;
  font-size: 16px;
  text-align: center;
  color: #000;
}

.recto_desc {
  height: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: #b0b0b0;
  text-align: center;
}

.recto_price {
  margin-top: 10px;
  color: #ff6700;
  font-size: 14px;
  text-align: center;
}

.flat {
  width: 992px;
  height: 614px;
}

.flat ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.flat li {
  width: 234px;
  height: 300px;
  background-color: #fff;
  transition: all .4s linear;
}

.flat ul li:nth-child(5),
.flat ul li:nth-child(6),
.flat ul li:nth-child(7),
.flat ul li:nth-child(8) {
  margin-top: 14px;
}

.flat ul li:hover {
  transform: translateY(1px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, .1);
}

.flat li img {
  display: block;
  width: 160px;
  height: 160px;
  overflow: hidden;
  margin: 10px auto;
}

.apparel {
  cursor: pointer;
  width: 992px;
  height: 614px;
}

.apparel ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.apparel li {
  width: 234px;
  height: 300px;
  background-color: #fff;
  transition: all .4s linear;
}

.apparel ul li:hover {
  transform: translateY(1px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, .1);
}

.apparel li a img {
  display: block;
  width: 160px;
  height: 160px;
  overflow: hidden;
  margin: 10px auto;
}

.tail-banner {
  margin: 30px auto;
  width: 1226px;
  height: 120px;
}

.apparel ul li:nth-child(5),
.apparel ul li:nth-child(6),
.apparel ul li:nth-child(7),
.apparel ul li:nth-child(8) {
  margin-top: 14px;
}

.tail-banner a img {
  margin: 0 auto;
  width: 100%;
  height: 100%;
}
</style>
